package com.xing.zrtest;

import okhttp3.*;

import java.io.IOException;

/**
 * @Author: ljx
 * @Date: 2021-07-21 14:46
 */
public class TestUserInfoZR {

    private static OkHttpClient client = new OkHttpClient();

    private static String getSign(String authCode, String authSecret, String uid) {
        String param = "&auth_code=" + authCode + "&uid="+uid;
        param += authSecret;

        return MD5.getInstance().getMD5String(param);
    }

    public static void main(String[] args) {
        String sign = getSign("600019", "oh379ho017t3neewmkxqk10orzfhikdt", "c7347c7f-8f43-4792-989e-6f61968421c7");
        System.out.println(sign);

        HttpUrl.Builder urlBuilder =HttpUrl.parse("")
                .newBuilder()
                .addQueryParameter("auth_code", "600019")
                .addQueryParameter("sign", sign)
                .addQueryParameter("uid", "c7347c7f-8f43-4792-989e-6f61968421c7");

        Request request1 = new Request.Builder().url(urlBuilder.build())
//                .addHeader("sign", sign)
//                .addHeader("uid", "c7347c7f-8f43-4792-989e-6f61968421c7")
                .build();

        client.newCall(request1).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                System.out.println(e.getMessage());
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                System.err.println(response.body().source());
                if(response.code() >= 200 && response.code() < 300) {
                    System.out.println(response.body().string());
                }
            }
        });

    }
}
